package br.net.atasacramental.log.business;
import java.util.Date;
import br.net.atasacramental.log.model.Log;
import br.net.atasacramental.log.dao.LogDAO;
import java.util.List;
import under.wsl.service.Service;
/**
 * @author alexandre.araujo
 */
public class LogBLL{
    private LogDAO dao = null;
    public LogBLL() {
        this.dao = new LogDAO();
    }
    @Service(cache=true)
    public List<Log> get(){
        return this.dao.get();
    }
    @Service()
    public Log getByIdLog(int idLog) {
        return this.dao.getByIdLog(idLog);
    }
    @Service()
    public List<Log> getByMomento(Date momento) {
        return this.dao.getByMomento(momento);
    }
    @Service()
    public List<Log> getByPeriodoMomento(Date DtaI,Date DtaF){
        return this.dao.getByPeriodoMomento(DtaI,DtaF);
    }
    @Service()
    public List<Log> getByIdUsuarioFk(int idUsuarioFk) {
        return this.dao.getByIdUsuarioFk(idUsuarioFk);
    }
    @Service()
    public List<Log> getByServico(String servico) {
        return this.dao.getByServico(servico);
    }
    @Service()
    public List<Log> getByArgs(String args) {
        return this.dao.getByArgs(args);
    }
    @Service(remove={"LogBLL.get"})   
    public int insert(Log l){    	
        l.setMomento(new Date());
        /*
    	String argsS = "";
    	int tmp = args.length;
    	for(int z=0;z<tmp;z++){
    		argsS+=args[z].toString()+"|";        		
    	}  
    	argsS = argsS.substring(0,argsS.lastIndexOf("|"));    	 
    	*/    	
        if(this.dao.insert(l)){            
            return l.getIdLog();
        }
        return 0;
    }
    @Service(remove={"LogBLL.get"})
    public boolean update(Log l){
        return this.dao.update(l);
    }
    @Service(remove={"LogBLL.get"})
    public boolean delete(Log l){
         return this.dao.delete(l);
    }  
}
